//头部滚动
//获取fromuser用户信息好友信息 滚动
function getfromuser(thisFromuser){
    if(IsPC()){
        PCorNot="pc";
    }else{
        PCorNot="not";
    }
    $.ajax({
        type:"GET",
        url:"https://www.pulu.com/webapi/api/pulunews/GetUserFrdReContentNew?userId="+thisFromuser,
        success:function(d){
            for(var i=0;i< d.Data.length;i++){
                var title=d.Data[i].userReco.title;
                if(d.Data[i].userReco.title.length>16&&PCorNot==="not"){
                    title=title.substring(0,16)+"...";
                }
                $("#swiper-container .swiper-wrapper").append("<div class='swiper-slide'><div class='relalist'><div onclick='gototest(this)' data-type='"+d.Data[i].userReco.type+"' data-id='"+d.Data[i].userReco.id+"' data-uid='"+d.Data[i].userId+"' data-shareid='"+d.Data[i].userReco.shareId+"'>  <div class='showlist'>"+title+"</div></div></div></div>");
            }
            //滚动
            mySwiper = new Swiper ('.swiper-container', {
                autoplay : 1,
                speed:3000,
                //pagination : '.swiper-pagination',
                loop : true
            });
        }
    });
}
if(/fromuser=[0-9a-z]+/.test(location.href)){
    var thisFromuser=(location.href).match(/fromuser=[0-9a-z]+/)[0].split("=")[1];
    getfromuser(thisFromuser);
}else if($.cookie("fromuser")){
    getfromuser($.cookie("fromuser"));
}

//点击滚动 判断能否进入
function gototest(e){
    if($.cookie("MYID")){
        //这里拼接的ID 为自己的ID
        if(is_weixn()){
            if(e.dataset.type==1){
                location.href="http://www.pulu.com/weixin/newsdetail.html?newsid="+e.dataset.id+"#fromuser="+$.cookie("MYID")+"#newsShareId="+e.dataset.shareid;
            }else if(e.dataset.type==2){
                location.href="http://www.pulu.com/weixin/questiondetail.html?qid="+e.dataset.id+"#fromuser="+$.cookie("MYID");
            }else if(e.dataset.type==3){
                location.href="http://www.pulu.com/weixin/shareexppage.html?eid="+e.dataset.id+"#fromuser="+$.cookie("MYID");
            }
        }
        else{
            if(e.dataset.type==1){
                location.href="newsdetail.html?newsid="+e.dataset.id+"#fromuser="+$.cookie("MYID")+"#newsShareId="+e.dataset.shareid;
            }else if(e.dataset.type==2){
                location.href="questiondetail.html?qid="+e.dataset.id+"#fromuser="+$.cookie("MYID");
            }else if(e.dataset.type==3){
                location.href="shareexppage.html?eid="+e.dataset.id+"#fromuser="+$.cookie("MYID");
            }
        }
    }else{
        if(/fromuser=[0-9a-z]+/.test(location.href)){
            var thisFromuser=(location.href).match(/fromuser=[0-9a-z]+/)[0].split("=")[1];
        }else if($.cookie("fromuser")&&/[0-9]/.test($.cookie("fromuser"))){
            var thisFromuser=$.cookie("fromuser");
        }
        //fromuser的id 为原ID
        if(e.dataset.type==1){
            location.href="http://www.pulu.com/weixin/index.html?newsid="+e.dataset.id+"&fromuser="+thisFromuser;
        }else if(e.dataset.type==2){
            location.href="http://www.pulu.com/weixin/index.html?qid="+e.dataset.id+"&fromuser="+thisFromuser;
        }else if(e.dataset.type==3){
            location.href="http://www.pulu.com/weixin/index.html?eid="+e.dataset.id+"&fromuser="+thisFromuser;
        }
    }
}